import request from '@/utils/request'

export const sendAiMessage = async (body) => {
    const response = await fetch(`${process.env.VUE_APP_AI_BASE_API}/api/v1/chat/completions`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        dataType: 'text/event-stream',
        body: JSON.stringify(body),
    });

    if (!response.ok) {
        throw new Error('Network response was not ok');
    }
    return response.body;
};

export const getAiList = () => {
    return request({
        url: "/api/v1/chat/models",
        method: 'get'
    })
}

export const getKeyword = (data) => {
    return request({
        url: "/console/promtHelper/getKeyword",
        method: 'post',
        data
    })
}

export const convertSqlPush = (data) => {
    return request({
        url: "/api/convertSql/push",
        method: 'post',
        data
    })
}